package com.spring.test.aop;

import com.spring.test.aop.impl.SlaverImpl;
import com.spring.test.aop.service.Slaver;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.lang.reflect.Proxy;

public class Main {

	public static void main(String[] args) throws InterruptedException {
		ApplicationContext context =
				new ClassPathXmlApplicationContext("classpath*:application-aop.xml");
		Slaver slaver = (Slaver) context.getBean("slaverImpl");
		//使用代理调用了JdkDynamicAopProxy.invoke
		slaver.work();
		System.out.printf(slaver.getClass().getName());
//		Thread.sleep(Integer.MAX_VALUE);
		System.out.println("over>>>>>>>>>>");















////Cglib动态代理（不实现接口）
//		SlaverImpl slaver = (SlaverImpl) context.getBean("slaverImpl");
//		//使用代理调用了JdkDynamicAopProxy.invoke
//		slaver.work();


//		System.out.println(">>>>>>>>>>"+slaver);
//		AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Object.class);
//		ApplicationContext context2 =
//				new FileSystemXmlApplicationContext("classpath*:application-aop.xml");
	}


}
